package com.pluszg.nutrition.common.bean;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;

/**
 * @author fengrz
 */
public abstract class BaseModel implements Serializable {

    protected static final Logger logger = LoggerFactory.getLogger(BaseModel.class);

    private static final long serialVersionUID = 1L;

    /**
     * 用作排序的字符串，不参与序列化
     */
    private transient String orderby;

    /**
     * 作为查询条件的ID序列，不参与序列化
     */
    private transient String ids;

    private String paySign;


    @JsonIgnore
    public String getOrderby() {
        return orderby;
    }


    public void setOrderby(String orderby) {
        if (orderby == null) {
            return;
        }
        if (!orderby.matches("((\\w+\\.)?\\w+\\s+(ASC|DESC|asc|desc)?\\s*,\\s*)*(\\w+\\.)?\\w+\\s+(ASC|DESC|asc|desc)?")) {
            throw new IllegalArgumentException("orderby:" + orderby);
        }
        this.orderby = orderby;
    }

    @JsonIgnore
    public String getIds() {
        return ids;
    }

    public String getPaySign() {
        return paySign;
    }


    public void setIds(String ids) {
        if (ids == null) {
            return;
        }
        if (!ids.matches("(\\d+,)*\\d+")) {
            throw new IllegalArgumentException("ids:" + ids);
        }
        this.ids = ids;
    }

}
